const fs = require("fs");
const download = require("download");
const data = fs.readFileSync("./wxyz.csv", "utf-8"); // 每一行为一个下载链接

const arr = data.split("\n");
let n = 30418; // 从第几行开始读取

const loop = async (val) => {
	let to = val;

	for (let i = 0; i < arr.length; i++) {
		const url = arr[i];
		if (i > n) {
			try {
				console.info(i);
				await download(url, "./imgs/", { filename: `${i}.jpg` });
			} catch (e) {
				console.error(e.message);
				console.error(
					"##################new life##################",
					val
				);
				// await loop(val);
			}
		}
	}
};

loop(n);